package
{
	import com.pesilo.module.ui.ScrollBarUI;
	import com.pesilo.util.AssetsUtil;
	import com.pesilo.util.UIUtil;
	
	import flash.display.Sprite;
	import flash.display.StageAlign;
	import flash.display.StageScaleMode;
	import flash.events.Event;
	import flash.text.TextField;
	
	[SWF(height="900")]
	public class ScrollBar extends Sprite
	{
		private var scrollBarUI:ScrollBarUI;
		private var contMask:Sprite
		private var scroll:ScrollBarDispatcher;
		private var mc:Sprite;
		
		private var sbu:ScrollBarUI;
		private var sbd:ScrollBarDispatcher;
		
		public function ScrollBar()
		{
			stage.align=StageAlign.TOP_LEFT;
			stage.scaleMode=StageScaleMode.NO_SCALE;
			
			var txt:TextField=new TextField();
			txt.width=10;
			txt.wordWrap=true;
			txt.text="1fasjdkflj22lasdjflsajdflskajlfk33jdslakjflksdjalkfjdslakjflks444ajdlkfjlakjfsalkfjaslkdf";
			txt.height=500;
			
			var cont:Sprite=AssetsUtil.getMask(0xff0000,100,500,0.7);
			contMask=AssetsUtil.getMask(0x55ff55,100,100,0.7);
			cont.addChild(txt);
			
			
			
			this.addChild(contMask);
			this.addChild(cont);
			contMask.x=50;
			cont.x=50;
			cont.mask=contMask;
			
			scrollBarUI=new ScrollBarUI();
			this.addChild(scrollBarUI);
			scrollBarUI.x=contMask.width+contMask.x;
			
			scroll=new ScrollBarDispatcher(scrollBarUI,false);
			scroll.setContent=cont;
			scroll.setViewport=contMask;
			cont.y=50;
			contMask.y=50;
			contMask.height=stage.stageHeight-contMask.y;
			scroll.init(true);
			
			
			stage.addEventListener(Event.RESIZE,__resizeHandle);
		}
		
		
		protected function __resizeHandle(e:Event):void
		{
			contMask.height=stage.stageHeight-contMask.y;
			
			scroll.init();
			
		}
	}
}